﻿using System;

namespace UFrame
{
    public class BoolToFloatConverter 
    {
        public float min = 0f;
        public float max = 1f;

        public  BoolToFloatConverter(){}

        public BoolToFloatConverter(float min, float max)
        {
            this.min = min;
            this.max = max;
        }
        
        public object Convert(object value)
        {
            bool b = System.Convert.ToBoolean(value);
            return b ? max : min;
        }

        public object ConvertBack(object value)
        {
            float b = System.Convert.ToSingle(value);
            return Math.Abs(b - min) < 0f;
        }
    }
}